<?php


if (!defined("EXPONENT")) exit("");
	$composer = null;
	if (isset($_GET['id'])) {
		$composer = $db->selectObject("composers","id=".$_GET['id']);
		if ($composer != null) {
			$loc = unserialize($composer->location_data);
		} 
	}
 
 if (!$composer)
    {
      $composer->file_id=0; // create new composer
    }
	
	if (exponent_permissions_check("manage",$loc)) {
		$config = $db->selectObject('composersmodule_config',"location_data='".serialize($loc)."'");
		if (!$config) {
			//do nothing here yes.
      $config->image_collection=0;
        
		}
		$form = composer::form($composer);
		$form->registerBefore('submit','file_id','Composer Image', new ajax_select_file('file_id',$config->image_collection,$composer->file_id,true));
		$form->location($loc);
		$form->meta("action","save");
				
		$template = new template("composersmodule","_form_edit",$loc);
		$template->assign("is_edit",(isset($composer->id) ? 1 : 0));
		$template->assign("form_html",$form->toHTML());
		$template->output();
	} else {
		echo SITE_403_HTML;
	}

?>
